package com.itnoob.service1;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author zhoujun
 * @date 2025/3/26 23:21
 */
@Service
public class B1 implements B {

    @Autowired
    private Mediator mediator;

    public B1(Mediator mediator) {
        this.mediator = mediator;
        //bean对象注册到中介者对象
        mediator.register(this);
    }

    @Override
    public void doSomething() {
        System.out.println("B1 do something....");
        //发送消息
        mediator.relay(this,"B1 done");
    }
}
